package com.xinyue.user.service.Impl;



import com.xinyue.user.dao.UserMapper;
import com.xinyue.user.pojo.User;
import com.xinyue.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) throws Exception {
        return userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(User record) throws Exception {
    	Date d=new Date();
    	record.setCreated(d);
    	record.setUpdated(d);
        return userMapper.insert(record);
    }

    @Override
    public User selectByPrimaryKey(Integer id) throws Exception {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> selectAll() throws Exception {
        return userMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(User record) throws Exception {
        return userMapper.updateByPrimaryKey(record);
    }

    @Override
    public User selectToLoginByUsername(String username, String password) throws Exception {
        return userMapper.selectToLoginByUsername(username, password);
    }

    @Override
    public User selectToLoginByPhone(String phone, String password) throws Exception {
        return userMapper.selectToLoginByPhone(phone, password);
    }

    @Override
    public User selectByPhone(String phone) throws Exception {
        return userMapper.selectByPhone(phone);
    }
}
